View Javadoc

1   // System.java, created Fri Aug 16 18:11:48 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.ClassLib.sun14_linux.java.lang;
5   
6   import joeq.Class.PrimordialClassLoader;
7   
8   /***
9    * System
10   *
11   * @author  John Whaley <jwhaley@alum.mit.edu>
12   * @version $Id: System.java 1456 2004-03-09 22:01:46Z jwhaley $
13   */
14  public abstract class System {
15      
16      private static java.util.Properties props;
17      private static native void setIn0(java.io.InputStream in);
18      private static native void setOut0(java.io.PrintStream out);
19      private static native void setErr0(java.io.PrintStream err);
20  
21      public static java.lang.String mapLibraryName(java.lang.String libname) {
22          return libname; // TODO.
23      }
24  
25      /****
26      public static void initializeSystemClass() {
27          props = new java.util.Properties();
28          initProperties(props);
29          sun.misc.Version.init();
30          java.io.FileInputStream fdIn = new java.io.FileInputStream(java.io.FileDescriptor.in);
31          java.io.FileOutputStream fdOut = new java.io.FileOutputStream(java.io.FileDescriptor.out);
32          java.io.FileOutputStream fdErr = new java.io.FileOutputStream(java.io.FileDescriptor.err);
33          setIn0(new java.io.BufferedInputStream(fdIn));
34          setOut0(new java.io.PrintStream(new java.io.BufferedOutputStream(fdOut, 128), true));
35          setErr0(new java.io.PrintStream(new java.io.BufferedOutputStream(fdErr, 128), true));
36  
37          //try {
38          //    java.util.logging.LogManager.getLogManager().readConfiguration();
39          //} catch (java.lang.Exception ex) {
40          //}
41  
42          //loadLibrary("zip");
43  
44          //sun.misc.VM.booted();
45      }
46      ***/
47      public static void loadLibrary(String libname) {
48          if (libname.equals("zip")) return;
49          Runtime.getRuntime().loadLibrary0(getCallerClass(), libname);
50      }
51      static native Class getCallerClass();
52  
53      private static java.util.Properties initProperties(java.util.Properties props) {
54          // TODO: read these properties from environment.
55          props.setProperty("java.class.version", "48.0");
56          props.setProperty("java.home", "/usr/java/j2sdk1.4.0_01/jre");
57          props.setProperty("java.runtime.name", "Java(TM) 2 Runtime Environment, Standard Edition");
58          props.setProperty("java.runtime.version", "1.4.0_01-b03");
59          props.setProperty("java.specification.name", "Java Platform API Specification");
60          props.setProperty("java.specification.vendor", "Sun Microsystems, Inc.");
61          props.setProperty("java.specification.version", "1.4");
62          props.setProperty("java.vendor", "joeq");
63          props.setProperty("java.vendor.url", "http://joeq.sourceforge.net");
64          props.setProperty("java.vendor.url.bug", "http://joeq.sourceforge.net");
65          props.setProperty("java.version", "1.4.0_01");
66          props.setProperty("java.vm.name", "joeq virtual machine");
67          props.setProperty("java.vm.specification.name", "Java Virtual Machine Specification");
68          props.setProperty("java.vm.specification.vendor", "Sun Microsystems, Inc.");
69          props.setProperty("java.vm.specification.version", "1.0");
70          props.setProperty("java.vm.vendor", "joeq");
71          props.setProperty("java.vm.version", "1.4.0_01-b03");
72          props.setProperty("java.util.prefs.PreferencesFactory", "java.util.prefs.FileSystemPreferencesFactory");
73          
74          props.setProperty("os.arch", "i386");
75          props.setProperty("os.name", "Linux");
76          props.setProperty("os.version", "2.4.9-31smp");
77          
78          props.setProperty("file.encoding", "ISO-8859-1");
79          props.setProperty("file.encoding.pkg", "sun.io");
80          props.setProperty("file.separator", "/");
81          
82          props.setProperty("line.separator", "\n");
83          
84          props.setProperty("path.separator", ":");
85          
86          props.setProperty("user.country", "US");
87          props.setProperty("user.dir", "/u/jwhaley/joeq");
88          props.setProperty("user.home", "/u/jwhaley");
89          props.setProperty("user.language", "en");
90          props.setProperty("user.name", "jwhaley");
91          props.setProperty("user.timezone", "");
92  
93          // must be at end: classpathToString() uses some properties from above.
94          props.setProperty("java.class.path", PrimordialClassLoader.loader.classpathToString());
95  
96          return props;
97      }
98      
99  }